<template>
<section @click="clickCurrent('current')" @mousedown="clickCurrent('dragging')">
    <div v-if="custormItemData.params.chooseItemList"  :class="['custorm--modelbox', 'goodsdb-show', (custormCurrent == custormIndex)?'drag active':'drag']">
        <div v-if="custormItemData.params.isshow == '2'" class="noshow" v-bind:style="{'background-image':`url(${getPath('noshow.png')})`}"></div>
        <div>
            <div v-if="custormItemData.style.display == '1'" class="es-goods-group  two block">
                <div>
                    <div class="es-goods-item" v-for="(_citem, _cindex) in (custormItemData.params.choostype == '2'||custormItemData.params.choostype == '3')? custormItemData.params.listitem:custormItemData.params.chooseItemList.length>0?custormItemData.params.chooseItemList:custormItemData.data" :key="_cindex">
                        <div :class="['image',custormItemData.style.icon=='2'?'showIcon':'']">
                            <div v-if="custormItemData.style.icon=='2'" class="icon-attr" v-bind:style="{'background-image':`url(${getPath('common_label2.png')})`}">{{custormItemData.style.icontext}}</div>
                            <img  :src="`${custormItemData.params.choostype != '1'?getPath('default_picture.png'):_citem.edit?getPath(_citem.edit.thumb):_citem.images[0]}`" alt="" draggable="false">
                            <div class="detail">
                                <div class="name line-hide" v-if="custormItemData.style.name">{{custormItemData.params.choostype != '1'?'这里是商品标题':_citem.edit?_citem.edit.name:_citem.title}}</div>
                                <div class="subtitle line-hide" v-if="custormItemData.style.subtitle">{{custormItemData.params.choostype != '1'?'这里是商品副标题':_citem.edit?_citem.subtitle:_citem.title}}</div>
                                <div style="display: flex;">
                                    <div style="flex: 1 1 0%;">
                                        <div class="price"><span class="text" v-if="custormItemData.style.price">￥<span>{{custormItemData.params.choostype != '1'?'20':_citem.edit?_citem.edit.price:_citem.subprice}}</span></span>
                                            <span class="productprice" v-if="custormItemData.style.oldprice">￥{{custormItemData.params.choostype != '1'?'99':_citem.edit?_citem.edit.oldprice:_citem.price}}</span>
                                        </div>
                                        <div class="sold" v-if="custormItemData.style.sales">
                                            <span class=" ">已售{{custormItemData.params.choostype != '1'?'0':_citem.edit?_citem.edit.sales:_citem.sales}}</span>
                                        </div>
                                    </div>
                                    <span v-if="custormItemData.style.buybtn == '1'&&custormItemData.style.buybtnstyle == '1'" class="buy buybtn1">购买</span>
                                    <span v-if="custormItemData.style.buybtn == '1'&&custormItemData.style.buybtnstyle == '2'" class="buy buybtn6">+</span>
                                    <span v-if="custormItemData.style.buybtn == '1'&&custormItemData.style.buybtnstyle == '3'" class="buy buybtn3"><i class="icon icon-cart"></i></span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div v-if="custormItemData.style.display == '2'" class="es-goods-group  list2">
                <div>
                    <div class="es-goods-item" v-for="(_citem, _cindex) in (custormItemData.params.choostype == '2'||custormItemData.params.choostype == '3')? custormItemData.params.listitem:custormItemData.params.chooseItemList.length>0?custormItemData.params.chooseItemList:custormItemData.data" :key="_cindex">
                        <div :class="['image',custormItemData.style.icon=='2'?'showIcon':'']">
                            <div v-if="custormItemData.style.icon=='2'" class="icon-attr" v-bind:style="{'background-image':`url(${getPath('common_label2.png')})`}">{{custormItemData.style.icontext}}</div>
                            <img :src="`${custormItemData.params.choostype != '1'?getPath('default_picture.png'):_citem.edit?getPath(_citem.edit.thumb):_citem.images[0]}`" alt="" draggable="false"></div>
                            <div class="detail">
                                <div class="name two-line-hide" v-if="custormItemData.style.name">{{custormItemData.params.choostype != '1'?'这里是商品标题':_citem.edit?_citem.edit.name:_citem.title}}</div>
                                <div style="display: flex;">
                                    <div style="flex: 1 1 0%;">
                                        <div class="price" v-if="custormItemData.style.price"><span class="text">￥<span>{{custormItemData.params.choostype != '1'?'20':_citem.edit?_citem.edit.price:_citem.subprice}}</span></span></div>
                                        <div class="sold"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="btn-edit-del" @click="delCurrent"><span class="btn-del icon icon-close"></span></div>
        </div>
</section>
</template>

<script>
import defaultConfig from './utils/showConfig'
export default {
  mixins: [defaultConfig.mixins],
  props: {
    defaultConfig: {
      type: Object,
      default: function() {
        return defaultConfig
      }
    }
  },
  methods: {

  }
}
</script>

<style lang="scss" scoped>
.custorm--modelbox.goodsdb-show {
    .block {
        display: block !important;
    }

    .es-goods-group {
        height: auto;
        background: #ffffffff;
    }

    .es-goods-item {
        position: relative;
        height: auto;
        padding: 14px;
        background: #fff;
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
    }

    .es-goods-group.block .es-goods-item {
        border-radius: 4px;
    }

    .es-goods-group.block .es-goods-item {
        width: 50%;
        float: left;
        border-bottom: 0;
        background: none;
        padding: 5px;
        display: block;
        border-radius: 2px;
    }

    .es-goods-group.list2 .es-goods-item:first-of-type,
    .es-goods-group.list2 .es-goods-item:nth-of-type(2) {
        padding-top: 14px;
    }

    .es-goods-group.list2 .es-goods-item {
        width: 50%;
        float: left;
        display: block;
        padding-right: 7px;
        border-bottom: 0;
        padding-top: 0;
    }

    .es-goods-group.block.two .es-goods-item {
        border: 1px solid #e5e5e5;
        padding: 0;
        margin: 5px 10px;
        box-sizing: border-box;
        width: 169px;
        border-radius: 2px;
    }

    .es-goods-item .image {
        height: 100px;
        width: 100px;
        float: left;
        background-size: cover;
        position: relative;
        background-repeat: no-repeat;
        background-position: 50%;
    }

    .es-goods-group.block .es-goods-item .image {
        width: 100%;
        height: auto;
        margin: 0;
        background-position: 50%;
        background-repeat: no-repeat;
        background-size: cover;
    }

    .es-goods-group.list2 .es-goods-item .image {
        width: 80px;
        height: 80px;
        border-radius: 4px;
    }

    .es-goods-group.block .es-goods-item .image {
        float: none;
    }

    .es-goods-item .image img {
        height: 100%;
        width: 100%;
        max-width: 100%;
        max-height: 100%;
        display: block;
    }

    .es-goods-group.block .es-goods-item .image img {
        width: 100%;
        display: block;
        max-width: 100%;
        max-height: 100%;
    }

    .es-goods-group.block.two .es-goods-item .image img {
        height: 172.5px;
    }

    .es-goods-item .detail {
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
        line-height: 1.5;
        background: #fff;
        padding-left: 10px;
        display: flex;
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        -webkit-box-orient: vertical;
        -ms-flex-direction: column;
        -webkit-flex-direction: column;
        flex-direction: column;
        -webkit-box-pack: justify;
        -ms-flex-pack: justify;
        -webkit-justify-content: space-between;
        justify-content: space-between;
    }

    .es-goods-group.block .es-goods-item .detail {
        padding: 8px;
        overflow: hidden;
        line-height: 1.5;
    }

    .es-goods-group .es-goods-item .detail .name {
        margin-top: 6px;
        font-size: 14px;
    }

    .es-goods-group .es-goods-item .detail .name {
        font-size: 13px;
        color: #3d404d;
        line-height: 1;
    }

    .line-hide,
    .two-line-hide {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .line-hide {
        white-space: nowrap;
    }

    .two-line-hide {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .line-hide,
    .two-line-hide {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .es-goods-group .es-goods-item .detail .subtitle {
        font-size: 12px;
        color: #999ca7;
        height: 18px;
        margin-top: 6px 0 4px;
    }

    .es-goods-item .detail .price {
        position: relative;
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-align: center;
        -webkit-align-items: center;
        -ms-flex-align: center;
        align-items: center;
        font-size: 14px;
    }

    .es-goods-item .detail .price .text {
        color: #fd463e;
        font-weight: 700;
        font-size: 13px;
    }

    .es-goods-group.list2 .es-goods-item .detail {
        height: 80px;
    }

    .es-goods-item .detail .price .text span {
        font-size: 16px;
    }

    .es-goods-group.list2 .es-goods-item .price .text span {
        font-size: 12px;
    }

    .es-goods-group .es-goods-item .detail .productprice {
        width: 100%;
        color: #999;
        font-size: 11px;
        overflow: hidden;
    }

    .es-goods-item .detail .price .productprice {
        text-decoration: line-through;
        color: #999;
        font-size: 12px;
    }

    .es-goods-group.block .es-goods-item .detail .productprice {
        height: 24px;
        line-height: 24px;
    }

    .es-goods-item .detail .sold {
        font-size: 11px;
        color: #999;
    }

    .two .es-goods-item .detail .sold {
        line-height: 22px;
    }

    .es-goods-group .es-goods-item .detail .sold {
        color: #999;
    }

    .es-goods-item .detail .buy {
        display: inline-block;
        height: 22px;
        color: #fff;
        line-height: 22px;
        padding: 0;
        width: 32px;
        border-radius: 2px;
        text-align: center;
        border: 1px solid transparent;
        float: right;
        -webkit-align-self: flex-end;
        -ms-flex-item-align: end;
        align-self: flex-end;
    }

    .es-goods-item .detail .buy.buybtn1 {
        border: 1px solid #f55;
        background: #f55;
    }

    .es-goods-item .detail .buy.buybtn3 {
        color: #f55;
        vertical-align: middle;
        width: 22px;
        padding: 0;
        text-align: center;
        line-height: 22px;
    }

    .es-goods-item .detail .buy.buybtn6 {
        vertical-align: middle;
        width: 22px;
        text-align: center;
        line-height: 22px;
        border-radius: 50%;
        color: #fff;
        background: #f55;
    }

    .es-goods-group:after {
        display: block;
        overflow: hidden;
        visibility: hidden;
        width: 0;
        height: 0;
        content: "";
        clear: both;
    }

    .es-goods-item .image.showIcon .icon-attr {
        position: absolute;
        top: -18px;
        left: -16px;
        width: 60px;
        height: 60px;
        background-size: 60px;
        background-repeat: no-repeat;
        z-index: 10;
        color: #fff;
        font-size: 21px;
        -webkit-transform: scale(.5);
        transform: scale(.5);
        padding-right: 7px;
        line-height: 12px;
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-align: center;
        -webkit-align-items: center;
        -ms-flex-align: center;
        align-items: center;
        -webkit-box-pack: center;
        -webkit-justify-content: center;
        -ms-flex-pack: center;
        justify-content: center;
    }

    .one .es-goods-item .image.showIcon .icon-attr,
    .two .es-goods-item .image.showIcon .icon-attr {
        position: absolute;
        top: -25px;
        left: -21px;
        width: 80px;
        height: 80px;
        background-size: 80px;
        z-index: 10;
        color: #fff;
        font-size: 21px;
        -webkit-transform: scale(.5);
        transform: scale(.5);
        padding-right: 7px;
        line-height: 12px;
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-align: center;
        -webkit-align-items: center;
        -ms-flex-align: center;
        align-items: center;
        -webkit-box-pack: center;
        -webkit-justify-content: center;
        -ms-flex-pack: center;
        justify-content: center;
    }

    .es-goods-group.block.two .es-goods-item:nth-of-type(2n),
    .es-goods-group.block.two>div:nth-of-type(2n) .es-goods-item {
        margin-left: 0;
    }
}
</style>
